/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package gamedslmm_m2m.impl;

import gamedslmm_m2m.Attribute;
import gamedslmm_m2m.GameObject;
import gamedslmm_m2m.Gamedslmm_m2mPackage;
import gamedslmm_m2m.Line;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Game Object</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link gamedslmm_m2m.impl.GameObjectImpl#getAttributes <em>Attributes</em>}</li>
 *   <li>{@link gamedslmm_m2m.impl.GameObjectImpl#getName <em>Name</em>}</li>
 *   <li>{@link gamedslmm_m2m.impl.GameObjectImpl#getStereotype <em>Stereotype</em>}</li>
 *   <li>{@link gamedslmm_m2m.impl.GameObjectImpl#getOutLines <em>Out Lines</em>}</li>
 *   <li>{@link gamedslmm_m2m.impl.GameObjectImpl#getInLines <em>In Lines</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class GameObjectImpl extends EObjectImpl implements GameObject {
	/**
	 * The cached value of the '{@link #getAttributes() <em>Attributes</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAttributes()
	 * @generated
	 * @ordered
	 */
	protected EList<Attribute> attributes;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getStereotype() <em>Stereotype</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStereotype()
	 * @generated
	 * @ordered
	 */
	protected static final String STEREOTYPE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getStereotype() <em>Stereotype</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStereotype()
	 * @generated
	 * @ordered
	 */
	protected String stereotype = STEREOTYPE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getOutLines() <em>Out Lines</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutLines()
	 * @generated
	 * @ordered
	 */
	protected EList<Line> outLines;

	/**
	 * The cached value of the '{@link #getInLines() <em>In Lines</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInLines()
	 * @generated
	 * @ordered
	 */
	protected EList<Line> inLines;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GameObjectImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Gamedslmm_m2mPackage.Literals.GAME_OBJECT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Attribute> getAttributes() {
		if (attributes == null) {
			attributes = new EObjectContainmentEList<Attribute>(Attribute.class, this, Gamedslmm_m2mPackage.GAME_OBJECT__ATTRIBUTES);
		}
		return attributes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Gamedslmm_m2mPackage.GAME_OBJECT__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getStereotype() {
		return stereotype;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStereotype(String newStereotype) {
		String oldStereotype = stereotype;
		stereotype = newStereotype;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Gamedslmm_m2mPackage.GAME_OBJECT__STEREOTYPE, oldStereotype, stereotype));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Line> getOutLines() {
		if (outLines == null) {
			outLines = new EObjectWithInverseResolvingEList<Line>(Line.class, this, Gamedslmm_m2mPackage.GAME_OBJECT__OUT_LINES, Gamedslmm_m2mPackage.LINE__SRC);
		}
		return outLines;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Line> getInLines() {
		if (inLines == null) {
			inLines = new EObjectWithInverseResolvingEList<Line>(Line.class, this, Gamedslmm_m2mPackage.GAME_OBJECT__IN_LINES, Gamedslmm_m2mPackage.LINE__TGT);
		}
		return inLines;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Gamedslmm_m2mPackage.GAME_OBJECT__OUT_LINES:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getOutLines()).basicAdd(otherEnd, msgs);
			case Gamedslmm_m2mPackage.GAME_OBJECT__IN_LINES:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getInLines()).basicAdd(otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Gamedslmm_m2mPackage.GAME_OBJECT__ATTRIBUTES:
				return ((InternalEList<?>)getAttributes()).basicRemove(otherEnd, msgs);
			case Gamedslmm_m2mPackage.GAME_OBJECT__OUT_LINES:
				return ((InternalEList<?>)getOutLines()).basicRemove(otherEnd, msgs);
			case Gamedslmm_m2mPackage.GAME_OBJECT__IN_LINES:
				return ((InternalEList<?>)getInLines()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Gamedslmm_m2mPackage.GAME_OBJECT__ATTRIBUTES:
				return getAttributes();
			case Gamedslmm_m2mPackage.GAME_OBJECT__NAME:
				return getName();
			case Gamedslmm_m2mPackage.GAME_OBJECT__STEREOTYPE:
				return getStereotype();
			case Gamedslmm_m2mPackage.GAME_OBJECT__OUT_LINES:
				return getOutLines();
			case Gamedslmm_m2mPackage.GAME_OBJECT__IN_LINES:
				return getInLines();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Gamedslmm_m2mPackage.GAME_OBJECT__ATTRIBUTES:
				getAttributes().clear();
				getAttributes().addAll((Collection<? extends Attribute>)newValue);
				return;
			case Gamedslmm_m2mPackage.GAME_OBJECT__NAME:
				setName((String)newValue);
				return;
			case Gamedslmm_m2mPackage.GAME_OBJECT__STEREOTYPE:
				setStereotype((String)newValue);
				return;
			case Gamedslmm_m2mPackage.GAME_OBJECT__OUT_LINES:
				getOutLines().clear();
				getOutLines().addAll((Collection<? extends Line>)newValue);
				return;
			case Gamedslmm_m2mPackage.GAME_OBJECT__IN_LINES:
				getInLines().clear();
				getInLines().addAll((Collection<? extends Line>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Gamedslmm_m2mPackage.GAME_OBJECT__ATTRIBUTES:
				getAttributes().clear();
				return;
			case Gamedslmm_m2mPackage.GAME_OBJECT__NAME:
				setName(NAME_EDEFAULT);
				return;
			case Gamedslmm_m2mPackage.GAME_OBJECT__STEREOTYPE:
				setStereotype(STEREOTYPE_EDEFAULT);
				return;
			case Gamedslmm_m2mPackage.GAME_OBJECT__OUT_LINES:
				getOutLines().clear();
				return;
			case Gamedslmm_m2mPackage.GAME_OBJECT__IN_LINES:
				getInLines().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Gamedslmm_m2mPackage.GAME_OBJECT__ATTRIBUTES:
				return attributes != null && !attributes.isEmpty();
			case Gamedslmm_m2mPackage.GAME_OBJECT__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case Gamedslmm_m2mPackage.GAME_OBJECT__STEREOTYPE:
				return STEREOTYPE_EDEFAULT == null ? stereotype != null : !STEREOTYPE_EDEFAULT.equals(stereotype);
			case Gamedslmm_m2mPackage.GAME_OBJECT__OUT_LINES:
				return outLines != null && !outLines.isEmpty();
			case Gamedslmm_m2mPackage.GAME_OBJECT__IN_LINES:
				return inLines != null && !inLines.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", stereotype: ");
		result.append(stereotype);
		result.append(')');
		return result.toString();
	}

} //GameObjectImpl
